﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Supplier/SupplierMasterPage.master"
    AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="Supplier_Price_Default" %>


<asp:Content ID="Content2" ContentPlaceHolderID="pnlMain" runat="Server">

    <script language="javascript">
        function ValidateDate(sender, args) {
            args.IsValid = isDate(args.Value);
        }
    </script>

    <table cellpadding="0" cellspacing="0">
        <tr>
            <td>
                <table cellpadding="3" cellspacing="3">
                    <tr>
                        <td id="tdSupplierHead" runat="server">
                            Suppliers
                        </td>
                        <td>
                            Locations
                        </td>
                        <td>
                            Vehicles
                        </td>
                    </tr>
                    <tr>
                        <td id="tdSupplierControl" runat="server">
                            <asp:DropDownList ID="ddlSuppliers" AutoPostBack="true" runat="server" OnSelectedIndexChanged="ddlSuppliers_SelectedIndexChanged">
                            </asp:DropDownList>
                        </td>
                        <td>
                            <asp:DropDownList ID="ddlLocations" AutoPostBack="true" runat="server" OnSelectedIndexChanged="ddlLocations_SelectedIndexChanged">
                            </asp:DropDownList>
                        </td>
                        <td>
                            <asp:DropDownList ID="ddlVehicles" AutoPostBack="true" runat="server" OnSelectedIndexChanged="ddlVehicles_SelectedIndexChanged">
                            </asp:DropDownList>
                        </td>
                    </tr>
                </table>
            </td>
        </tr>
        <tr>
            <td>
                <asp:Panel ID="pnlSeasonPrice" runat="server">
                    <asp:Literal ID="ltrMessage" runat="server"></asp:Literal>
                    <table cellpadding="0" cellspacing="0">
                        <col width="100" />
                        <col width="600" />
                        <tr>
                            <td colspan="2">
                                <h3>
                                    Add New Season</h3>
                            </td>
                        </tr>
                        <tr>
                            <td>
                                Start Date
                            </td>
                            <td>
                                <asp:TextBox ID="txtStartDateAdd" runat="server" MaxLength="10" Width="100"></asp:TextBox><asp:RequiredFieldValidator
                                    ID="rfvStartDateAdd" ControlToValidate="txtStartDateAdd" ValidationGroup="VGADD"
                                    runat="server" ErrorMessage="*" Display="Dynamic"></asp:RequiredFieldValidator><asp:CustomValidator
                                        ID="cvStartDateAdd" runat="server" ErrorMessage="Invalid Date" Display="Dynamic"
                                        ControlToValidate="txtStartDateAdd" ValidationGroup="VGADD" SetFocusOnError="true"
                                        EnableClientScript="true" ClientValidationFunction="ValidateDate"></asp:CustomValidator>
                            </td>
                        </tr>
                        <tr>
                            <td>
                                End Date
                            </td>
                            <td>
                                <asp:TextBox ID="txtEndDateAdd" runat="server" MaxLength="10" Width="100"></asp:TextBox><asp:RequiredFieldValidator
                                    ID="rfvEndDateAdd" ControlToValidate="txtEndDateAdd" ValidationGroup="VGADD"
                                    runat="server" ErrorMessage="*" Display="Dynamic"></asp:RequiredFieldValidator><asp:CustomValidator
                                        ID="cvEndDateAdd" runat="server" ErrorMessage="Invalid Date" Display="Dynamic"
                                        ControlToValidate="txtEndDateAdd" ValidationGroup="VGADD" SetFocusOnError="true"
                                        EnableClientScript="true" ClientValidationFunction="ValidateDate"></asp:CustomValidator>
                            </td>
                        </tr>
                        <tr>
                            <td>
                                Rent Price
                            </td>
                            <td>
                                <asp:TextBox ID="txtRentPriceAdd" runat="server" MaxLength="5" Width="100"></asp:TextBox><asp:RequiredFieldValidator
                                    ID="RequiredFieldValidator1" ControlToValidate="txtRentPriceAdd" ValidationGroup="VGADD"
                                    runat="server" ErrorMessage="*" Display="Dynamic"></asp:RequiredFieldValidator><asp:RegularExpressionValidator
                                        ID="RegularExpressionValidator1" runat="server" ErrorMessage="Invalid Value"
                                        ControlToValidate="txtRentPriceAdd" ValidationGroup="VGADD" ValidationExpression="\d{1,2}(?:\.\d{1,2})?$"
                                        Display="Dynamic"></asp:RegularExpressionValidator>
                            </td>
                        </tr>
                        <tr id="trPercentMargin" runat="server">
                            <td>
                                % Margin
                            </td>
                            <td>
                                <asp:TextBox ID="txtPercentMarginAdd" runat="server" MaxLength="5" Width="100"></asp:TextBox><asp:RequiredFieldValidator
                                    ID="RequiredFieldValidator1SellPriceAdd" ControlToValidate="txtPercentMarginAdd"
                                    ValidationGroup="VGADD" runat="server" ErrorMessage="*" Display="Dynamic"></asp:RequiredFieldValidator><asp:RegularExpressionValidator
                                        ID="RegularExpressionValidator1PercentMarginAdd" runat="server" ErrorMessage="Invalid Value"
                                        ControlToValidate="txtPercentMarginAdd" ValidationGroup="VGDD" ValidationExpression="\d{1,2}(?:\.\d{1,2})?$"
                                        Display="Dynamic"></asp:RegularExpressionValidator>
                            </td>
                        </tr>
                         <tr id="trActualMargin" runat="server" >
                            <td>
                                Actual Margin
                            </td>
                            <td>
                                <asp:TextBox ID="txtActualMarginAdd" runat="server" MaxLength="5" Width="100"></asp:TextBox><asp:RequiredFieldValidator
                                    ID="RequiredFieldValidator2" ControlToValidate="txtActualMarginAdd"
                                    ValidationGroup="VGADD" runat="server" ErrorMessage="*" Display="Dynamic"></asp:RequiredFieldValidator><asp:RegularExpressionValidator
                                        ID="RegularExpressionValidator1ActualMarginAdd" runat="server" ErrorMessage="Invalid Value"
                                        ControlToValidate="txtActualMarginAdd" ValidationGroup="VGDD" ValidationExpression="\d{1,2}(?:\.\d{1,2})?$"
                                        Display="Dynamic"></asp:RegularExpressionValidator>
                            </td>
                        </tr>
                        <tr>
                            <td colspan="2">
                                &nbsp;
                            </td>
                        </tr>
                        <tr>
                            <td colspan="2">
                                <asp:Button ID="btnAdd" runat="server" Text="Add" ValidationGroup="VGADD" OnClick="btnAdd_Click" />
                            </td>
                        </tr>
                        <tr>
                            <td colspan="2">
                                &nbsp;
                            </td>
                        </tr>
                    </table>
                    <asp:GridView ID="gvSeasons" Width="100%" runat="server" AutoGenerateColumns="False" DataKeyNames="PriceOnSeasonId"
                        EmptyDataText="There are no data records to display." OnRowCancelingEdit="gvSeasons_RowCancelingEdit"
                        OnRowDataBound="gvSeasons_RowDataBound" OnRowDeleted="gvSeasons_RowDeleted" OnRowDeleting="gvSeasons_RowDeleting"
                        OnRowEditing="gvSeasons_RowEditing" OnRowUpdated="gvSeasons_RowUpdated" OnRowUpdating="gvSeasons_RowUpdating">
                        <Columns>
                            <asp:TemplateField HeaderText="Start Date">
                                <EditItemTemplate>
                                    <asp:TextBox ID="txtStartDateEdit" runat="server" MaxLength="10" Width="100"></asp:TextBox><asp:RequiredFieldValidator
                                        ID="rfvStartDateEdit" ControlToValidate="txtStartDateEdit" ValidationGroup="VGEDIT"
                                        runat="server" ErrorMessage="*" Display="Dynamic"></asp:RequiredFieldValidator><asp:CustomValidator
                                            ID="cvStartDateEdit" runat="server" ErrorMessage="Invalid Date" Display="Dynamic"
                                            ControlToValidate="txtStartDateEdit" ValidationGroup="VGEDIT" SetFocusOnError="true"
                                            EnableClientScript="true" ClientValidationFunction="ValidateDate"></asp:CustomValidator>
                                </EditItemTemplate>
                                <ItemTemplate>
                                    <asp:Label ID="lblStartDate" runat="server"></asp:Label>
                                </ItemTemplate>
                            </asp:TemplateField>
                            <asp:TemplateField HeaderText="End Date">
                                <EditItemTemplate>
                                    <asp:TextBox ID="txtEndDateEdit" runat="server" MaxLength="10" Width="100"></asp:TextBox><asp:RequiredFieldValidator
                                        ID="rfvEndDateEdit" ControlToValidate="txtEndDateEdit" ValidationGroup="VGEDIT"
                                        runat="server" ErrorMessage="*" Display="Dynamic"></asp:RequiredFieldValidator><asp:CustomValidator
                                            ID="cvEndDateEdit" runat="server" ErrorMessage="Invalid Date" Display="Dynamic"
                                            ControlToValidate="txtEndDateEdit" ValidationGroup="VGEDIT" SetFocusOnError="true"
                                            EnableClientScript="true" ClientValidationFunction="ValidateDate"></asp:CustomValidator>
                                </EditItemTemplate>
                                <ItemTemplate>
                                    <asp:Label ID="lblEndDate" runat="server"></asp:Label>
                                </ItemTemplate>
                            </asp:TemplateField>
                            <asp:TemplateField HeaderText="Rent Price">
                                <EditItemTemplate>
                                    <asp:TextBox ID="txtRentPriceEdit" runat="server" MaxLength="5" Width="100"></asp:TextBox><asp:RequiredFieldValidator
                                        ID="RequiredFieldValidator1" ControlToValidate="txtRentPriceEdit" ValidationGroup="VGEDIT"
                                        runat="server" ErrorMessage="*" Display="Dynamic"></asp:RequiredFieldValidator><asp:RegularExpressionValidator
                                            ID="RegularExpressionValidator1" runat="server" ErrorMessage="Invalid Value"
                                            ControlToValidate="txtRentPriceEdit" ValidationGroup="VGEDIT" ValidationExpression="\d{1,2}(?:\.\d{1,2})?$"
                                            Display="Dynamic"></asp:RegularExpressionValidator>
                                </EditItemTemplate>
                                <ItemTemplate>
                                    <asp:Label ID="lblRentPrice" runat="server"></asp:Label>
                                </ItemTemplate>
                            </asp:TemplateField>
                            <asp:TemplateField HeaderText="% Margin">
                                <EditItemTemplate>
                                    <asp:TextBox ID="txtPercentMarginEdit" runat="server" MaxLength="5" Width="100"></asp:TextBox><asp:RequiredFieldValidator
                                        ID="RequiredFieldValidator1PercentMarginEdit" ControlToValidate="txtPercentMarginEdit"
                                        ValidationGroup="VGEDIT" runat="server" ErrorMessage="*" Display="Dynamic"></asp:RequiredFieldValidator><asp:RegularExpressionValidator
                                            ID="RegularExpressionValidator1PercentMarginEdit" runat="server" ErrorMessage="Invalid Value"
                                            ControlToValidate="txtPercentMarginEdit" ValidationGroup="VGEDIT" ValidationExpression="\d{1,2}(?:\.\d{1,2})?$"
                                            Display="Dynamic"></asp:RegularExpressionValidator>
                                </EditItemTemplate>
                                <ItemTemplate>
                                    <asp:Label ID="lblPercentMargin" runat="server"></asp:Label>
                                </ItemTemplate>
                            </asp:TemplateField>
                            <asp:TemplateField HeaderText="Actual Margin">
                                <EditItemTemplate>
                                    <asp:TextBox ID="txtActualMarginEdit" runat="server" MaxLength="5" Width="100"></asp:TextBox><asp:RequiredFieldValidator
                                        ID="RequiredFieldValidator1ActualMarginEdit" ControlToValidate="txtActualMarginEdit"
                                        ValidationGroup="VGEDIT" runat="server" ErrorMessage="*" Display="Dynamic"></asp:RequiredFieldValidator><asp:RegularExpressionValidator
                                            ID="RegularExpressionValidator1ActualMarginEdit" runat="server" ErrorMessage="Invalid Value"
                                            ControlToValidate="txtActualMarginEdit" ValidationGroup="VGEDIT" ValidationExpression="\d{1,2}(?:\.\d{1,2})?$"
                                            Display="Dynamic"></asp:RegularExpressionValidator>
                                </EditItemTemplate>
                                <ItemTemplate>
                                    <asp:Label ID="lblActualMargin" runat="server"></asp:Label>
                                </ItemTemplate>
                            </asp:TemplateField>
                            <asp:TemplateField>
                                <ItemTemplate>
                                    <asp:LinkButton ID="lnkEdit" CausesValidation="false" CommandName="Edit" runat="server"
                                        Text="Edit"></asp:LinkButton>
                                </ItemTemplate>
                                <EditItemTemplate >
                                    <asp:LinkButton ID="lnkSave" CausesValidation="true" runat="server" CommandName="Update"
                                        ValidationGroup="VGEDIT" Text="Update"></asp:LinkButton>
                                    &nbsp
                                    <asp:LinkButton ID="lnkCancel" CausesValidation="false" runat="server" CommandName="Cancel"
                                        Text="Cancel"></asp:LinkButton>
                                </EditItemTemplate>
                                
                            </asp:TemplateField>
                            <asp:CommandField ShowDeleteButton="True" />
                        </Columns>
                    </asp:GridView>
                    <asp:GridView ID="gvSuppSeasons" Width="100%" runat="server" AutoGenerateColumns="False" DataKeyNames="PriceOnSeasonId"
                        EmptyDataText="There are no data records to display." OnRowCancelingEdit="gvSuppSeasons_RowCancelingEdit"
                        OnRowDataBound="gvSuppSeasons_RowDataBound" OnRowDeleted="gvSuppSeasons_RowDeleted" OnRowDeleting="gvSuppSeasons_RowDeleting"
                        OnRowEditing="gvSuppSeasons_RowEditing" OnRowUpdated="gvSuppSeasons_RowUpdated" OnRowUpdating="gvSuppSeasons_RowUpdating">
                        <Columns>
                            <asp:TemplateField HeaderText="Start Date">
                                <EditItemTemplate>
                                    <asp:TextBox ID="txtStartDateEdit" runat="server" MaxLength="10" Width="100"></asp:TextBox><asp:RequiredFieldValidator
                                        ID="rfvStartDateEdit" ControlToValidate="txtStartDateEdit" ValidationGroup="VGEDIT"
                                        runat="server" ErrorMessage="*" Display="Dynamic"></asp:RequiredFieldValidator><asp:CustomValidator
                                            ID="cvStartDateEdit" runat="server" ErrorMessage="Invalid Date" Display="Dynamic"
                                            ControlToValidate="txtStartDateEdit" ValidationGroup="VGEDIT" SetFocusOnError="true"
                                            EnableClientScript="true" ClientValidationFunction="ValidateDate"></asp:CustomValidator>
                                </EditItemTemplate>
                                <ItemTemplate>
                                    <asp:Label ID="lblStartDate" runat="server"></asp:Label>
                                </ItemTemplate>
                            </asp:TemplateField>
                            <asp:TemplateField HeaderText="End Date">
                                <EditItemTemplate>
                                    <asp:TextBox ID="txtEndDateEdit" runat="server" MaxLength="10" Width="100"></asp:TextBox><asp:RequiredFieldValidator
                                        ID="rfvEndDateEdit" ControlToValidate="txtEndDateEdit" ValidationGroup="VGEDIT"
                                        runat="server" ErrorMessage="*" Display="Dynamic"></asp:RequiredFieldValidator><asp:CustomValidator
                                            ID="cvEndDateEdit" runat="server" ErrorMessage="Invalid Date" Display="Dynamic"
                                            ControlToValidate="txtEndDateEdit" ValidationGroup="VGEDIT" SetFocusOnError="true"
                                            EnableClientScript="true" ClientValidationFunction="ValidateDate"></asp:CustomValidator>
                                </EditItemTemplate>
                                <ItemTemplate>
                                    <asp:Label ID="lblEndDate" runat="server"></asp:Label>
                                </ItemTemplate>
                            </asp:TemplateField>
                            <asp:TemplateField HeaderText="Rent Price">
                                <EditItemTemplate>
                                    <asp:TextBox ID="txtRentPriceEdit" runat="server" MaxLength="5" Width="100"></asp:TextBox><asp:RequiredFieldValidator
                                        ID="RequiredFieldValidator1" ControlToValidate="txtRentPriceEdit" ValidationGroup="VGEDIT"
                                        runat="server" ErrorMessage="*" Display="Dynamic"></asp:RequiredFieldValidator><asp:RegularExpressionValidator
                                            ID="RegularExpressionValidator1" runat="server" ErrorMessage="Invalid Value"
                                            ControlToValidate="txtRentPriceEdit" ValidationGroup="VGEDIT" ValidationExpression="\d{1,2}(?:\.\d{1,2})?$"
                                            Display="Dynamic"></asp:RegularExpressionValidator>
                                </EditItemTemplate>
                                <ItemTemplate>
                                    <asp:Label ID="lblRentPrice" runat="server"></asp:Label>
                                </ItemTemplate>
                            </asp:TemplateField>
                            <asp:TemplateField>
                                <ItemTemplate>
                                    <asp:LinkButton ID="lnkEdit" CausesValidation="false" CommandName="Edit" runat="server"
                                        Text="Edit"></asp:LinkButton>
                                </ItemTemplate>
                                <EditItemTemplate >
                                    <asp:LinkButton ID="lnkSave" CausesValidation="true" runat="server" CommandName="Update"
                                        ValidationGroup="VGEDIT" Text="Update"></asp:LinkButton>
                                    &nbsp
                                    <asp:LinkButton ID="lnkCancel" CausesValidation="false" runat="server" CommandName="Cancel"
                                        Text="Cancel"></asp:LinkButton>
                                </EditItemTemplate>
                                
                            </asp:TemplateField>
                            <asp:CommandField ShowDeleteButton="True" />
                        </Columns>
                    </asp:GridView>
                </asp:Panel>
            </td>
        </tr>
    </table>
</asp:Content>
